/********************************************************/
/*	LuaScript class by George Chew						*/
/*	For use in GeorgeLib								*/
/*	Created Mar 2013									*/
/*														*/
/*	Version 0001										*/
/********************************************************/

#ifndef __LUASCRIPT_H__
#define __LUASCRIPT_H__

#include "stdafx.h"
#include <cstdarg>	// stdarg.h for argument list

#define LUA_BUILD_AS_DLL

extern "C"
{
	#include <lua/lua.h>
	#include <lua/lualib.h>
	#include <lua/lauxlib.h>
}

	/*		How to use this class	*/
	// Lua->LoadFile("mylua.lua");
	// int a = Lua->getFunctioni("func", "ifb", 234, 26.43, true);

class LuaScript
{
private:
	static	LuaScript*	LuaScript_Instance;	// Singleton Instance

public:
	static	lua_State*	theLuaState;		// Define the Lua Stat

	LuaScript(void);	// Constructor
	~LuaScript(void);	// Destructor

	// Get the singleton instance of this class
	static	LuaScript*	getInstance			(void);

			void		NewState			(void);

	// Initialise a file to use
	// You are able to use getFunction and getVariable only after
	// a file is initialised
			bool		LoadFile			(char * FileName);
	
	// Get results from a function in your file
	// FuncName		:	the name of your function in your .lua file
	// ParamTypes	:	the types of your arguments passed
	//					'b' : boolean
	//					'i' : int
	//					'f' : float
	//					'd' : double
	//					's' : char* (c-string)
	//
	// Example call :
	// int a = Lua->getFunctioni("func", "bifds", true, 5, 5.5, 5.55, "five");
			int			getFunci			(char * FuncName, char * ParamTypes, ...);
			float		getFuncf			(char * FuncName, char * ParamTypes, ...);
			double		getFuncd			(char * FuncName, char * ParamTypes, ...);
			char*		getFuncs			(char * FuncName, char * ParamTypes, ...);
			int			getFuncb			(char * FuncName, char * ParamTypes, ...);

	// Get a variable from your file
	// VarName		:	the name of your variable (duh)
	//
	// Example call:
	// int a = Lua->getVariablei("variable");
			int			getVari			(char * VarName);
			float		getVarf			(char * VarName);
			double		getVard			(char * VarName);
			char*		getVars			(char * VarName);
			int			getVarb			(char * VarName);

};
#endif // __LUASCRIPT_H__ //